<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='./vue.js'></script>
</head>

<body>
    <div id='app'>
        <div>
            <h1>父组件 {{ count }} </h1>
            <!-- 因为 count 是在父组件中定义的所以父组件中可以修改 -->
            <button @click="count++">修改 count</button>
        </div>
        <hr>

        <counter :count="count" />
    </div>
</body>

<template id="counter">
    <div>
        <h1>子组件 {{count}}</h1>
        <button @click="count++">修改</button>
    </div>
</template>
<!-- 

    vue 中所谓的单向数据流，就是子组件只能使用父组件传递过来的数据，但是不能修改

 -->
<script>

    // 子组件
    const counter = {
        template: '#counter',
        props: ['count']
    }

    const app = {
        data() {
            return {
                count: 100
            }
        },
        methods: {},
        components: {
            counter
        }
    }
    const vm = Vue.createApp(app).mount('#app')
</script>

</html>